import java.util.HashSet;
import java.util.Set;

/**
 * @ClassName LC961
 * @Author ykx
 * @Date 2024/6/29 16:48
 * @Version 1.0
 */
public class LC961 {
    public static void main(String[] args) {
        System.out.println(new LC961().repeatedNTimes(new int[]{5, 1, 5, 2, 5, 3, 5, 4}));
    }

    public int repeatedNTimes(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            if (!set.add(num)) {
                return num;
            }
        }
        return 0;
    }

}
